Skip to content

feat(nameresolving): add system resolver worker pool and factory - #3384

Merged
richard-ramos merged 9 commits into
masterfrom
feat/system-resolver-backend
Nov 11, 2026
Merged

richard-ramos merged 9 commits into
masterfrom
feat/system-resolver-backend

Conversation

@richard-ramos

@richard-ramos richard-ramos commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Resolve names through the host's OS configuration, including hosts files, localhost, and container DNS. Blocking lookups run on a lazily created worker pool; TXT queries use the system DNS servers discovered by the parent PR.

Add newNameResolver: omitting the server list selects SystemResolver; supplying a list selects DnsResolver, including an empty list that returns no DNS results. Cover family filtering, concurrent lookups, cancellation, asynchronous shutdown, concurrent stops, reopening, and real switch integration.

Impact on Library Users

Import libp2p/nameresolving. newNameResolver(rng) returns a SystemResolver. The caller must await its stop() after stopping dependent switches. Workers start lazily on first use; start() permits reuse after shutdown.

newNameResolver(rng, servers) returns a DnsResolver, which requires no lifecycle calls. Passing either resolver to withNameResolver leaves ownership with the caller. A TXT resolver supplied to SystemResolver.new also remains caller-managed: the system resolver does not start or stop it.

The system resolver requires threads, and shutdown waits asynchronously for active OS lookups. Unless a TXT resolver is supplied, construction discovers TXT nameservers synchronously and can block the calling thread while reading system configuration.

Stack

2 of 3 — merge in this order:

  1. #3379: system DNS discovery; base master.
  2. This PR: system resolver worker pool and factory; base feat/system-name-resolver.
  3. #3385: bounded multiaddress expansion; base feat/system-resolver-backend.

All three PRs are drafts. Review this diff against its parent branch.

Validation

System-resolver suite, including caller-managed lifecycle and real switch DNS dialing: 13 checks passed after rebasing.

References

Closes #3378. Continues the resolver implementation from #3114, originally authored by @nate-staked.

@richard-ramos

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 2 issue(s) in this PR.

  • ✅ Successfully posted inline: 2 comment(s)

Model: qwen3.8-max
Review generated in: 18m 25s

Comment thread libp2p/nameresolving.nim Resolved
Comment thread libp2p/nameresolving.nim Resolved
@richard-ramos
richard-ramos force-pushed the feat/system-resolver-backend branch 3 times, most recently from 7aa78f4 to c06c767 Compare November 5, 2026 23:07
@richard-ramos
richard-ramos marked this pull request as ready for review November 5, 2026 23:10
@richard-ramos
richard-ramos requested review from a team, gmelodie and vladopajic November 5, 2026 23:10
Comment thread tests/libp2p/test_system_resolve.nim Resolved
Comment thread libp2p/nameresolving.nim Resolved
Comment thread tests/libp2p/test_system_resolve.nim Resolved
Comment thread tests/libp2p/test_system_resolve.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
Comment thread libp2p/nameresolving/systemresolver.nim Resolved
@richard-ramos
richard-ramos marked this pull request as draft November 10, 2026 13:52
@richard-ramos
richard-ramos marked this pull request as ready for review November 10, 2026 13:52
@richard-ramos
richard-ramos force-pushed the feat/system-resolver-backend branch from 6efc3d1 to 24f8026 Compare November 11, 2026 13:33
Base automatically changed from feat/system-name-resolver to master November 11, 2026 15:37
@richard-ramos
richard-ramos force-pushed the feat/system-resolver-backend branch from 2257983 to 4980680 Compare November 11, 2026 15:37
@richard-ramos
richard-ramos added this pull request to the merge queue Nov 11, 2026
Merged via the queue into master with commit 2bbbdd0 Nov 11, 2026
43 of 44 checks passed
@richard-ramos
richard-ramos deleted the feat/system-resolver-backend branch November 11, 2026 17:18
@github-project-automation github-project-automation Bot moved this from new to done in nim-libp2p Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(nameresolving): add a system name resolver and a NameResolver factory

3 participants